﻿/*=========================================================================
 * AUTH: Matthew Baum, 9753095
 * DESC: Game Level Obstacles
 *=========================================================================*/

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace RisingThreat
{
    // A cubic obstacle
    class CubicObstacle : QuadTreeItem
    {
        // Obstacle dimensions
        private static readonly float CUBIC_OBS_DIMS = LevelTile.TILE_WIDTH;
        private static readonly float CUBIC_OBS_Y_OFFSET = (CUBIC_OBS_DIMS + LevelTile.TILE_HEIGHT) / 2;

        // Obstacle color
        private static readonly Color CUBIC_OBS_COLOR = Color.BlueViolet;

        // Visual Representation of the obstacle
        private RectPrism obstacle;

        // CONSTRUCTOR
        public CubicObstacle(int xOffset, int zOffset, GraphicsDevice graphicsDevice)
        {
            // Calculate position of tile from offsets
            float xPos = xOffset * CUBIC_OBS_DIMS;
            float zPos = zOffset * CUBIC_OBS_DIMS;

            // Create new prism to represent the tile
            obstacle = new RectPrism
                (
                    new Vector3(xPos, CUBIC_OBS_Y_OFFSET, zPos), 
                    CUBIC_OBS_DIMS,
                    CUBIC_OBS_COLOR,
                    graphicsDevice
                );
        }

        // Draw the obstacle
        public void draw(GraphicsDeviceManager graphics, BasicEffect effect)
        {
            obstacle.draw(graphics, effect);
        }

        // IMPLEMENTATION: Get bounding volume from geometry
        BoundingBox QuadTreeItem.getBoundingVolume()
        {
            return obstacle.getBoundingBox();
        }

        // Get faces
        Plane[] QuadTreeItem.getFaces()
        {
            return obstacle.getFaces();
        }
    }
}
